package src;

import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.concurrent.ArrayBlockingQueue;

import javax.sound.sampled.Line;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineListener;
import javax.sound.sampled.SourceDataLine;

public class LineListen implements LineListener, Runnable {
	private SourceDataLine li;
	private Queue<Byte[]> fileAttente;
	private Queue<Integer> fileDeux;
	boolean fin = false;

	public LineListen() {
		fileAttente = new ArrayBlockingQueue<Byte[]>(1);
	}
	public void fin(){
		fin=true;
	}
	public void add(Byte[] by, int nbRead) {
		fileAttente.add(by);
		fileDeux.add(nbRead);
	}

	@Override
	public void update(LineEvent arg) {
		System.out.println(arg.getFramePosition());

	}

	@Override
	public void run() {
		while (!fin) {
			Byte[] temp = fileAttente.peek();

			li.write(t, 0, fileDeux.peek().intValue());
			
		}

	}

}
